# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
from django.db import models
from apps.resource import register
from apps.resource.Resource import Resource


# 可以通过继承来覆盖默认方法
class MyResource(Resource):
    cannot_see_fields = ['id', 'passwd']


# 这里注册了所有 model, 正式项目中应该有选择的进行注册
for model in models.get_models():
    register('api', model, Resource)
    # 支持一个 model 多个 api
    register('another_api', model, MyResource)


urlpatterns = patterns('',
    (r'^$', 'django.views.generic.simple.direct_to_template',
            {'template': 'index.html'}),
    (r'^admin/', include('django.contrib.admin.urls')),
    (r'^(?P<key>api)/', include('apps.resource.urls')),
    (r'^(?P<key>another_api)/', include('apps.resource.urls')),
)
